<template>
  <c-row-add
    v-show="visible"
    :title="multLang('模版新增')"
    class="wot-template-add"
  >
    <el-form
      :model="form"
      :rules="rules"
      ref="form"
      label-width="140px"
      :validate-on-rule-change="false"
    >
      <c-row :col="11">
        <c-col>
          <el-form-item
            :label="multLang('模版名称', ':')"
            prop="work_template_name"
          >
            <el-input
              v-model="form.work_template_name"
              :placeholder="multLang('text_d')"
            ></el-input>
          </el-form-item>
        </c-col>
        <c-col>
          <el-form-item :label="multLang('模版描述', ':')" prop="remark">
            <c-input-text v-model="form.remark"></c-input-text>
          </el-form-item>
        </c-col>
      </c-row>
    </el-form>
  </c-row-add>
</template>
<script>
import { addTemplateData } from '@/http/api/v1/wot'
export default {
  name: 'TemplateAdd',
  components: {},
  props: {
    visible: { type: Boolean, default: false }
  },
  data() {
    return {
      form: {
        work_template_name: '',
        remark: ''
      }
    }
  },
  computed: {
    rules() {
      return {
        work_template_name: {
          required: true,
          message: this.multLang('模版名称', 'msg_g'),
          trigger: 'blur'
        }
      }
    }
  },
  watch: {},
  beforeCreate() {},
  created() {},
  beforeMount() {},
  mounted() {},
  beforeUpdate() {},
  updated() {},
  activated() {},
  deactivated() {},
  beforeDestroy() {},
  destroyed() {},
  methods: {
    reset() {
      this.$refs.form.resetFields()
    },
    submit() {
      this.$refs.form.validate(
        v =>
          v &&
          addTemplateData(this.form).then(({ code }) => {
            if (code === 200) {
              this.reset()
              this.$emit('update:visible', false)
              this.$emit('query')
            }
          })
      )
    }
  }
}
</script>
<style lang="scss">
.wot-template-add {
}
</style>
